package com.javabasic.algorithm.leetcode;

import java.util.HashSet;

/**
 * @author xiongmin
 * @version 0.0.1
 * @description Created by work on 2021/11/1 8:03 上午
 * @see [575. Distribute Candies](https://leetcode-cn.com/problems/distribute-candies/)
 */
public class DistributeCandies {

    /**
     * 思维逻辑题
     * @param candyType
     * @return
     */
    public int distributeCandies(int[] candyType) {
        HashSet<Integer> set = new HashSet<>();
        int length = candyType.length;
        for (int i = 0; i < length; i++) {
            set.add(candyType[i]);
        }
        if (set.size() < length/2) {
            return set.size();
        } else {
            return length/2;
        }
    }
}
